<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%user}}".
 *
 * @property integer $id
 * @property string $openid
 * @property string $union_id
 * @property string $nickname
 * @property string $mobile
 * @property string $avatar
 * @property integer $create_time
 * @property integer $role   角色
 * @property integer $referee 推荐人
 * @property integer $parent_code 推荐人id的层级拼接code
 * @property integer $invite_num  邀请合伙人分享次数
 * @property integer $invite_open_num 邀请合伙人分享被打开次数
 */
class UserModel extends \yii\db\ActiveRecord
{
    /**
     * @var int 普通用户
     */
    const ROLE_USER = 1;
    /**
     * @var int 合伙人
     */
    const ROLE_PARTNER = 2;
    /**
     * @var int 超级合伙人（相当于平台）
     */
    const ROLE_SUPER_PARTNER = 0;

    /**
     * @var array 所有的角色列表
     */
    const ROLE_LIST = [self::ROLE_USER,self::ROLE_PARTNER];
    
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%user}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['create_time','referee','role','invite_num','invite_open_num'], 'integer'],
            [['openid', 'union_id', 'nickname'], 'string', 'max' => 50],
            [['avatar'], 'string', 'max' => 150],
            [['mobile'], 'string', 'max' => 20],
            [['parent_code'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'openid' => 'Openid',
            'union_id' => 'Union ID',
            'nickname' => '昵称',
            'mobile' => '电话',
            'avatar' => 'Avatar',
            'create_time' => 'Create Time',
            'role'=>'role',
            'referee'=>'referee',
            'invite_num'=>'邀请分享数',
            'invite_open_num'=>'分享阅读数'
        ];
    }


}
